$(function() {
	$("#editpw").bind("click", function() {
		var oldpwResult = checkPasswd($("#oldpw").val());
		if (!oldpwResult.result) {
			$.alert(oldpwResult.msg);
			return false;
		}
		var newpwResult = checkPasswd($("#newpw").val());
		if (!newpwResult.result) {
			$.alert(newpwResult.msg);
			return false;
		}
		var repwResult = checkRePasswd($("#newpw").val(), $("#renewpw").val());
		if (!repwResult.result) {
			$.alert(repwResult.msg);
			return false;
		}
		$.showLoading();
		$.ajax({
			type : "post",
			url : appPath + "/setting/editpwsubmit.html",
			data : {
				oldpw : $.md5($("#oldpw").val() + $("#key1").val()),
				newpw : $.md5($("#newpw").val() + $("#key1").val()),
				key1 : $("#key1").val(),
				token : $.cookie("token")
			},
			success : function(result) {
				$.hideLoading();
				$.alert(result.msg, function() {
					if (result.code == '1') {
						history.go(-1);
					} else if (result.code == -1){
						window.location = appPath + "/member/login.html";
					}
				});
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				$.hideLoading();
	            $.alert("系统异常，请稍后再试");
	        }
		});
	});
})